package org.usfirst.team3132.demo.libs;

/**
 *
 * @author Matt
 */
public class Queue {
    private Node top = null;
    private Node bottom = null;
    
    private class Node {
        double val;
        Node prev;
    }
    
    public void push (double val) {
        Node cur = new Node();
        cur.val = val;
        if (top == null) {
            bottom = cur;
        } else {
            top.prev = cur;
        }
        top = cur;
    }
    
    public void clear()
    {
        top = null;
        bottom = null;
    }
    
    public Double pop () {
        if (bottom == null) {
            return null;
        }
        Node cur = bottom;
        bottom = cur.prev;
        if (bottom == null) {
            top = null;
        }
        
        return new Double(cur.val);
    }
}

